{template 'common/header'}
<ul class="nav nav-tabs">
	<li class="active">
		<a href="{php echo $this->createWebUrl('manager')}">资源文件管理</a>
	</li>
</ul>

<div class="panel panel-info">
	<div class="panel-heading">筛选</div>
	<div class="panel-body">
		<form action="{php echo $this->createWebUrl('manager')}" method="get" class="form-horizontal" role="form" id="form1">
			<input type="hidden" name="c" value="site" /> <input type="hidden"
				name="a" value="entry" /> <input type="hidden" name="m"
				value="yonny_mgrfile" />
				<input type="hidden" name="do" id="do"
				value="manager" />
				<input type="hidden" name="op" id="op"
				value="search" />
			<div class="form-group">
				<label class="col-xs-12 col-sm-1 col-md-1 col-lg-1 control-label">查询</label>
				<div class="col-sm-2 col-lg-2 col-xs-12">
					<input type="text" class="form-control" name="name" value="{$_GPC['name']}" placeholder="名称" />
				</div>
				<div class="col-sm-1 col-lg-1 col-xs-12">
					<button class="btn btn-default">
						<i class="fa fa-search"></i>
						搜索
					</button>
				</div>
			</div>
		</form>
	</div>
</div>
<div class="clearfix">
	<div class="panel panel-default">
		<div class="panel-heading">
			<a class="btn btn-default" href="javascript:;" data-toggle="modal" data-target="#modal-add-ad" onclick="setEdit('','')">
				<i class="fa fa-plus"></i>
				添加资源文件
			</a>
		</div>
		<div class="panel-body">
			<table class="table table-hover" style="overflow: visible;">
				<thead class="navbar-inner">
					<tr>
						<th width="160px">名称</th>
						<th width="120px">上传时间</th>
						<th width="380px">下载链接(复制后直接使用)</th>
						<th style='width: 140px;'>操作</th>
					</tr>
				</thead>
				<tbody>
					{loop $list $row}
					<tr>
						<td>{$row['name']}</td>
						<td>
							{php echo date('Y-m-d H:i:s', $row['createtime'])}
						</td>
						<td style="overflow:visible;position:relative;">
						<input type="text"  name="" style="display:none;" value="{$resourcepath}&id={$row['id']}">
						<span class="js-clip btn-default" style="cursor:pointer">复制链接</span>
						</td>
						<td>
							<a href="{php echo $this->createWebUrl('manager', array('id' => $row['id'],'op'=>'del'))}" onclick="return confirm('删除文件将无法找回，确认删除?')" class="btn btn-default btn-sm" data-toggle="tooltip" data-placement="top" title="删除">
								<i class="fa fa-remove"></i>
							</a>
							<a href="javascript:;" onclick="setEdit('{$row['id']}','{$row['name']}')" data-toggle="modal" data-target="#modal-add-ad" class="btn btn-default btn-sm" title="修改">
								<i class="fa fa-edit"></i>
							</a>
						</td>
					</tr>
					{/loop}
				</tbody>
			</table>
			{$pager}
		</div>
	</div>
</div>


<!-- 添加幻灯片 -->
<div id="modal-add-ad" class="modal fade" tabindex="-1" role="dialog" aria-hidden="true" style="width: 620px; margin: 0px auto;">
	<form class="form-horizontal form" action="{php echo $this->createWebUrl('manager',array(op=>'save'))}" method="post" enctype="multipart/form-data">
		<div class="modal-dialog">
			<div class="modal-content">
				<div class="modal-header">
					<button aria-hidden="true" data-dismiss="modal" class="close" type="button">×</button>
					<h3>添加资源文件</h3>
				</div>
				<div class="modal-body">
					<div class="form-group">
						<label class="col-xs-10 col-sm-3 col-md-3 control-label">名称</label>
						<div class="col-sm-6 col-xs-12">
							<input name="name" class="form-control" required id="name"/>
							<input name="id" class="form-control" id="id" type="hidden"/>
						</div>
					</div>
					<div class="form-group">
						<label class="col-xs-10 col-sm-3 col-md-3 control-label">文件</label>
						<div class="col-sm-6 col-xs-12">
							<input name="file" class="form-control" required type="file" />
						</div>
					</div>
				</div>
				<div class="modal-footer">
					<button type="submit" class="btn btn-primary span2" name="add-ad" value="yes">确  认</button>
					<a href="#" class="btn" data-dismiss="modal" aria-hidden="true">关  闭</a>
				</div>
			</div>
		</div>
	</form>
</div>
<script>
function  setEdit(id,name)
{
	$("#name").val(name);
	$("#id").val(id);
}
$(function(){
	require(['jquery.zclip'], function(){
		$('.js-clip').each(function(){
			var copy_button = this;
			$(copy_button).zclip({
				path: './resource/components/zclip/ZeroClipboard.swf',
				copy: $(copy_button).prev().val(),
				afterCopy: function(){
					$(copy_button).text('复制成功');
					setTimeout(function(){
						$(copy_button).text('复制链接');
					}, 2000);
				}
			});
		});
	});
});

</script>
{template 'common/footer'}
